#include "EPluginXml.h"
#include "DefineCommon.h"
#include "EItem.h"
#include <EItemManager.h>
#include <WidgetXml.h>
#include <WidgetsManager.h>
#include <QMenu>
#include <TabToolbar/TabToolbar.h>
#include <TabToolbar/Page.h>
#include <TabToolbar/Group.h>

// #include <Autogen/EItemInPlugin_autogen.h>
// #include <Autogen/EItemInPluginParent_autogen.h>

void registUi()
{
    WidgetXml* wXml = new WidgetXml();
    WidgetsManager::instance()->addWidgetToMap("WidgetXml", wXml);
    tt::Page* pageCommon = dynamic_cast<tt::Page*>(WidgetsManager::instance()->getWidgetFromMap("PageCommon"));
    tt::Group* groupNew = pageCommon->AddGroup("xml");
    groupNew->AddAction(QToolButton::ToolButtonPopupMode::InstantPopup, wXml->getAction("actionTestXml"));

}

EPluginXml::EPluginXml()
{

}

EPluginXml::~EPluginXml()
{

}

EString EPluginXml::getName()
{
    return EString("Xml");
}

EString EPluginXml::getDescription()
{
    return EString("A plugin that provides xml parsing functions to show Xmlnode struct and propteries.");
}

void EPluginXml::registThis()
{
    /**regist type to EItemManager*/
    EItemPtr typeRoot = NewSmartPtr(EItem)();
    typeRoot->setName("PluginXml");

    EItemManager::instance()->addToItemTypeRoot(typeRoot);

    ELOG_INFO("EPluginXml is registed");

    registUi();
}
    
EPluginPtr EPluginExportFunction()
{
    EPluginPtr pp = new EPluginXml;

    return pp;
}
